import { WebviewWindow } from '@tauri-apps/api/window'

let appUpdateWindow: WebviewWindow | null = null

const openUpdateWindow = () => {
  appUpdateWindow = new WebviewWindow('appUpdateWindow', {
    url: '/src/windows/update/index.html',
    title: 'Bs App Update',
    hiddenTitle: true,
    titleBarStyle: 'transparent',
    height: 200,
    width: 400,
  })

  appUpdateWindow.once('tauri://created', function () {})

  appUpdateWindow.once('tauri://error', function () {})
}

const closeUpdateWindow = () => {
  if (appUpdateWindow) {
    appUpdateWindow.close()
    appUpdateWindow = null
  }
}

export { openUpdateWindow, closeUpdateWindow }
